package com.nf.health.app.activity.home;

import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.LinearLayout;
import android.widget.TextView;


import com.nf.health.app.MyApplication;
import com.nf.health.app.R;
import com.nf.health.app.activity.global.BaseActivity;
import com.nf.health.app.activity.home.bean.Hospitalbean;
import com.nf.health.app.http.Apis;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 医院介绍   Ian 2017-04-07
 * Created by Administrator on 2017/4/7.
 */
public class HospitalIntroductionActivity extends BaseActivity {
    public static  String HID = "com.nf.hid";
    @Bind(R.id.titlebar_title_tv)
    TextView titlebarTitleTv;
    @Bind(R.id.ll_content)
    LinearLayout llContent;

    private String hid;
    WebView webview;

//    @Bind(R.id.tv_hospital_name)
//    TextView tvHospitalName;//医院名称
//    @Bind(R.id.tv_hospital_lv)
//    TextView tvHospitalLv;//医院等级
//    @Bind(R.id.tv_hospital_address)
//    TextView tvHospitalAddress;//医院地址
//    @Bind(R.id.tv_hospital_introduction)
//    TextView tvHospitalIntroduction;//医院简介

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTitleBar(R.layout.titlebar_base);
        setContent(R.layout.layout_activity_hospital_duction);
        ButterKnife.bind(this);
        initView();
    }

    private void initView() {
        hid = getIntent().getStringExtra(HID);
        titlebarTitleTv.setText("医院介绍");
        provider.requestHospitalIntroduce("introduce",hid);

        webview = new WebView(MyApplication.getInstance());
        llContent.addView(webview);
        WebSettings webSettings = webview.getSettings();
        webSettings.setBuiltInZoomControls(false);//屏幕缩放控件显示
        webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
        webSettings.setUseWideViewPort(true);
        webSettings.setJavaScriptEnabled(true);
        webSettings.setSupportZoom(true);//屏幕缩放
        webSettings.setLightTouchEnabled(true);
        webSettings.setAllowFileAccess(true);
        webSettings.setDomStorageEnabled(true);

    }

    @Override
    public void handleActionSuccess(String actionName, Object object) {
        super.handleActionSuccess(actionName, object);

        if ("introduce".equals(actionName)) {
            Hospitalbean hospitalbean = (Hospitalbean) object;
            webview.loadUrl(hospitalbean.getTourl()+ Apis.WEBVIEW_PLETEFORM);
        }

    }
}
